package com.huamao.niceman.scrollviewpager.classify.view;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.huamao.niceman.scrollviewpager.R;
import com.huamao.niceman.scrollviewpager.base.BaseActivity;
import com.huamao.niceman.scrollviewpager.base.BaseFragment;
import com.huamao.niceman.scrollviewpager.base.BasePresent;
import com.huamao.niceman.scrollviewpager.classify.present.ClassifyPresent;
import com.huamao.niceman.scrollviewpager.utils.FragmentInterface;
import com.huamao.niceman.scrollviewpager.widget.LQRDropdownLayout;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by LuanXianSheng on 2017/6/14.
 * 分类
 */

public class ClassifyFragment extends BaseFragment implements FragmentInterface {
    @BindView(R.id.classify_downlayout)
    LQRDropdownLayout mDownlayout;
    private List<Map<String, String>> selectDatas;
    private ClassifyPresent mPresent;
    private BaseActivity act;

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        act = (BaseActivity) context;
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        creatPresent();
        View view = inflater.inflate(R.layout.fragment_classify, null);
        ButterKnife.bind(this, view);
        return view;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        init();
        setData();
    }

    @Override
    public BasePresent creatPresent() {
        mPresent = new ClassifyPresent(this);
        return mPresent;
    }

    @Override
    public void init() {
        selectDatas = new ArrayList<>() ;
        mDownlayout.setCols(2);
    }

    @Override
    public void setData() {
        for (int i = 0;i<mDownlayout.getCols();i++){
            Map<String,String> map = new LinkedHashMap<>() ;
            if (i == 0){
                map.put("白羊座 ","白羊座");
                map.put("金牛座 ","金牛座");
                map.put("双子座 ","双子座");
                map.put("巨蟹座 ","巨蟹座");
                map.put("狮子座 ","狮子座");
                map.put("处女座 ","处女座");
                map.put("天秤座 ","天秤座");
                map.put("天蝎座 ","天蝎座");
                map.put("射手座 ","射手座");
                map.put("摩羯座 ","摩羯座");
                map.put("水瓶座 ","水瓶座");
                map.put("双鱼座 ","双鱼座");
            }else if (i ==1){
                map.put("今天 ","today");
                map.put("明天 ","tomorrow");
                map.put("本周","week");
                map.put("下周","nextweek");
                map.put("本月","month");
                map.put("今年","year");
            }
            selectDatas.add(map) ;
        }
        mDownlayout.init(null,selectDatas);
        mDownlayout.setOnDropdownListListener(new LQRDropdownLayout.OnDropdownListListener() {
            @Override
            public void OnDropdownListSelected(int indexOfButton, int indexOfList, String textOfList, String valueOfList) {
            }
            @Override
            public void onDropdownListOpen() {
            }

            @Override
            public void onDropdownListClosed() {
            }
        });
    }

    @Override
    public void getData(Object object) {

    }
}
